<?php
namespace app\models;

use Yii;
use yii\base\Model;

class OpenedSearch extends Opened
{

    public function rules()
    {
        return [
            ['comid', 'string', 'message' => 'comid必须是字符串', 
                      'min' => 8, 'tooShort' => 'comid最短8位', 
                      'max' => 8, 'tooLong' => 'comid最长8位'],
        ];
    }

    public function scenarios()
    {
        return Model::scenarios();
    }

    public function search($params)
    {
        $data['OpenedSearch'] = $params;
        // P($data);

        $query = Opened::find();

        if (!($this->load($data) && $this->validate())) {
            return false;
        }
        // P($this);
        if(isset($this->comid)){
            $query -> andWhere([
                'comid' => $this->comid,
            ]);
        }

        $query -> andFilterWhere(['!=', 'appid', ""]);


        return $query;
    }

    
}